package com.common.tools;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

public class RequestTools {

    public static String getHeaders(HttpServletRequest request) {
        Enumeration<String> e = request.getHeaderNames();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements()) {
            String n = e.nextElement();
            sb.append(n).append(":").append(request.getHeader(n)).append(";");
        }
        return sb.toString();
    }

    public static String getRequestParam(HttpServletRequest request) {
        Enumeration<String> e = request.getParameterNames();
        StringBuilder sb = new StringBuilder();
        while (e.hasMoreElements()) {
            String n = e.nextElement();
            sb.append(n).append(":").append(request.getParameter(n)).append(";");
        }
        return sb.toString();
    }
}
